import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:material_collection_app/utils/utils.dart';
import 'package:material_collection_app/widget/common/refresh.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

class EmptyTips extends StatefulWidget {
  final String tips;
  final RefreshController refreshController;
  final onRefresh;
  final Color backgroundColor;

  EmptyTips({
    Key key,
    this.tips = '暂无记录~',
    this.refreshController,
    this.onRefresh,
    this.backgroundColor = Colors.white
  }) 
  : super(key: key);

  @override
  State<StatefulWidget> createState() => MyState();
}

class MyState extends State<EmptyTips> {
  
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false);

    return Container(
      height: double.infinity,
      color: widget.backgroundColor,
      child: Refresh(
        enablePullUp: false,
        refreshController: widget.refreshController,
        onRefresh: () => widget.onRefresh(),
        child: Column(
          children: <Widget>[
            Container(
              margin: EdgeInsets.only(top: 160.w),
              child: Image.asset('assets/empty_data.png',
                width: 328.w
              ),
            ),
            Container(
              margin: EdgeInsets.only(top: 50.w),
              child: Text(widget.tips, style: TextStyle(
                color: Utils.hexToColor('#CCCCCC'),
                fontSize: 31.w
              )),
            )
          ]
        )
      )
    );
  }
}